Skip to content

SchemaView performance improvements - #1479

Merged
aruniverse merged 20 commits into
mainfrom
rschili/schema-view-fragment
Jul 28, 2026
Merged

SchemaView performance improvements#1479
aruniverse merged 20 commits into
mainfrom
rschili/schema-view-fragment

Conversation

@rschili

@rschili rschili commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

itwinjs-core: iTwin/itwinjs-core#9431

New schema view fragment pragma that will be used by iTwinjs-core to load just subsets of an iModels' schema.
Plus a few fixes, please read the linked itwinjs-core PR description and issue for full details.

Comment thread iModelCore/ECDb/ECDb/ConcurrentQueryManagerImpl.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends ECDb’s ECSQL pragma surface to support incremental SchemaView loading (fragments) for iTwinjs-core, and introduces a cheap schema identity hash (schema_token) intended for cache invalidation and determinism checks.

Changes:

  • Add PRAGMA schema_view_fragment(...) to return a subset of schemas as a SchemaView-format blob for incremental loading.
  • Add PRAGMA checksum(schema_token) backed by a new “name+version only” schema identity hash, and align schema_view’s schemaToken with it.
  • Refactor/extend SchemaViewWriter to support fragment filtering and safer state reuse; reduce noisy parameter-missing logs in concurrent query limit binding.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
iModelCore/ECDb/Tests/NonPublished/ECSqlPragmasTests.cpp Updates checksum/token assertions and adds coverage for schema_token and schema_view_fragment behavior.
iModelCore/ECDb/ECDb/SchemaViewWriter.h Adds fragment-related API/state and clarifies non-concurrent instance usage.
iModelCore/ECDb/ECDb/SchemaViewWriter.cpp Implements fragment filtering, request validation, centralized reset, and safer narrowing for serialized fields.
iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.h Extends checksum docs/options and declares schema_view_fragment + schema-token hashing support.
iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.cpp Implements checksum(schema_token), shared schema_view row building, and schema_view_fragment argument parsing.
iModelCore/ECDb/ECDb/ECDbImpl.cpp Registers the new schema_view_fragment pragma handler.
iModelCore/ECDb/ECDb/ConcurrentQueryManagerImpl.cpp Uses TryGetParameterIndex to avoid log spam when LIMIT/OFFSET params don’t exist (e.g., PRAGMAs).

Comment thread iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.cpp Outdated
Comment thread iModelCore/ECDb/ECDb/ECSql/ECSqlPragmas.cpp Outdated
rschili and others added 2 commits June 26, 2026 12:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rschili
rschili marked this pull request as ready for review July 23, 2026 15:57
@rschili
rschili enabled auto-merge (squash) July 24, 2026 09:43
@rschili
rschili disabled auto-merge July 24, 2026 09:43
// because the pragma grammar allows only one. Schema names are ECNames, so a ';' always means a
// version prefix.
uint8_t requestedVersion = CURRENT_FORMAT_VERSION;
Utf8String nameList = arg;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are just doing parsing of arg here. Can't we use string_view here? instead of string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, done. The version-prefix parsing now works on std::string_view slices over the single
materialized argument string; nameList stays a suffix of it, so its data() remains a valid
null-terminated string for BeStringUtilities::Split. The per-token Utf8Strings stay - Trim,
ECNameValidation::IsValidName and the bind need them anyway.

Comment thread iModelCore/ECDb/ECDb/SchemaViewWriter.cpp
@rschili

rschili commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

/azp run imodel-native

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rschili

rschili commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

/azp run imodel-native

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@aruniverse
aruniverse merged commit 2f2ce18 into main Jul 28, 2026
22 checks passed
@aruniverse
aruniverse deleted the rschili/schema-view-fragment branch July 28, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants